{include file="public/header" /}
<style>
    .layui-form-item{
        margin-bottom: 5px
    }
    .layui-form-label{
        width: 172px;
    }
    .layui-input-block{
        margin-left: 180px
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑私人订制库存</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">


                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">剩余库存：</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" value="{$stock.stock_number}" disabled>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">方式：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="type" value="1" class="layui-input" title="增加" checked />
                                <input type="radio" name="type" value="2" class="layui-input" title="减少"/>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">数量：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="number" lay-verify="required" placeholder="数量" class="layui-input" oninput="value=value.replace(/[^\d.]+/g,'')">
                            </div>
                        </div>

                        <input type="hidden" value="{$stock.stock_id}" name="stock_id">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">添加
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}

<script>
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('privateStockEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            wk.layer_close();
                        })
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>

</body>
</html>
